package 代码记录.指定公司代码练习记录.西安.分值100分;

import java.util.*;

/**
 * @author zx
 * @create 2023-06-28 10:22
 * 我的思路方便理解：对Map的value排序
 */
public class 阿里巴巴找黄金宝箱2 {//应该可以做出来
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String str = sc.nextLine();
        String[] arr = str.split(",");
        LinkedHashMap<Integer,Integer> map = new LinkedHashMap<>();
        for(int i = 0;i < arr.length;i++){
            int n = Integer.parseInt(arr[i]);
            if(map.containsKey(n)){
                map.put(n,map.get(n) + 1);
            }else{
                map.put(n,1);
            }
        }
        List<Map.Entry<Integer,Integer>> entries = new ArrayList<>(map.entrySet());
        Collections.sort(entries, new Comparator<Map.Entry<Integer, Integer>>() {
            @Override
            public int compare(Map.Entry<Integer, Integer> o1, Map.Entry<Integer, Integer> o2) {
                return o2.getValue() - o1.getValue();
            }
        });
        int count = 0;
        int res = 0;
        int size = arr.length / 2;
        for(int i = 0;i < entries.size();i++){
            count += entries.get(i).getValue();
            res++;
            if(count > size) {
                System.out.println(res);
                break;
            }
        }
    }
}
